package longrise.phone.com.bjjt_jyb.compensate;

import android.content.Context;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.longrise.android.FormParameter;
import com.longrise.android.FrameworkManager;
import com.longrise.android.LFView;

import longrise.phone.com.bjjt_jyb.R;

public class ChooseAccidentTypeView extends LFView implements View.OnClickListener {
    private Context context = null;
    private View view = null;
    private String appCaseno;
    private LinearLayout hn_btn_back;
    private RelativeLayout rl_choosesingle;
    private RelativeLayout rl_choosetwo;
    private RelativeLayout rl_choosethree;

    public ChooseAccidentTypeView(Context c, String appCaseNo) {
        super(c);
        this.context = c;
        this.appCaseno = appCaseNo;
    }

    @Override
    public void refreshByTime() {

    }

    @Override
    public FormParameter getFormParameter() {
        FormParameter fp = new FormParameter();
        fp.setShowtitle(false);
        return fp;
    }

    @Override
    public void refresh() {

    }

    @Override
    public View getView() {
        return view;
    }

    @Override
    public void init() {
        initView();
        regEvent(true);
    }

    private void initView() {
        view = View.inflate(context, R.layout.chooseaccidenttype, null);
        hn_btn_back = (LinearLayout) view.findViewById(R.id.hn_btn_back);
        rl_choosesingle = (RelativeLayout) view.findViewById(R.id.rl_choosesingle);
        rl_choosetwo = (RelativeLayout) view.findViewById(R.id.rl_choosetwo);
        rl_choosethree = (RelativeLayout) view.findViewById(R.id.rl_choosethree);
        TextView tv_title = (TextView) view.findViewById(R.id.tv_title);
        tv_title.setText("选择事故类型");
    }

    private void regEvent(boolean b) {
        if (null != hn_btn_back) {
            hn_btn_back.setOnClickListener(b ? this : null);
        }
        if (null != rl_choosesingle) {
            rl_choosesingle.setOnClickListener(b ? this : null);
        }
        if (null != rl_choosetwo) {
            rl_choosetwo.setOnClickListener(b ? this : null);
        }
        if (null != rl_choosethree) {
            rl_choosethree.setOnClickListener(b ? this : null);
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.hn_btn_back:
                closeForm();
                OnDestroy();
                break;
            case R.id.rl_choosesingle:
                //进入单车事故
                AccidentLoadingPictureView singlecaraccidentloadingpicview = new AccidentLoadingPictureView(context, appCaseno, 0,0);
                FrameworkManager.getInstance().showNewForm(context, singlecaraccidentloadingpicview);
                break;
            case R.id.rl_choosetwo:
                //进入双车事故
                AccidentLoadingPictureView accidentloadingpictureview = new AccidentLoadingPictureView(context, appCaseno,0,1);
                FrameworkManager.getInstance().showNewForm(context, accidentloadingpictureview);
                break;
            case R.id.rl_choosethree:
                //进入选择机动车和非机动车的事故类型
                ChooseAccidentTypeNewView chooseaccidenttypenewview = new ChooseAccidentTypeNewView(context, appCaseno);
                FrameworkManager.getInstance().showNewForm(context, chooseaccidenttypenewview);
                break;
        }
    }
}
